package alan.mybatisPlusDb.module.order.service.impl;

import alan.mybatisPlusDb.module.order.entity.TOrder;
import alan.mybatisPlusDb.module.order.mapper.TOrderMapper;
import alan.mybatisPlusDb.module.order.service.ITOrderService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author alan
 * @since 2021-03-03
 */
@Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements ITOrderService {

    @Override
    @DS("sharding")
    public Boolean save2Share(TOrder tOrder) {
        return this.save(tOrder);
    }

    @Override
    @DS("master")
    public Boolean save2Master(TOrder tOrder) {
        return this.save(tOrder);
    }

    @Override
    @DS("sharding")
    public List<TOrder> getByOrderIdWithShare(Long id) {
        return new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,id).list();
    }

    @Override
    @DS("master")
    public List<TOrder> getByOrderIdWithMaster(Long id) {
        return new LambdaQueryChainWrapper<>(baseMapper).eq(TOrder::getOrderId,id).list();
    }
}
